package cn.iocoder.yudao.module.erp.service.dpeast;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.erp.controller.admin.dpitem.dpeastlist.vo.DpEastListPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.dpitem.dpeastlist.vo.DpEastListSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.dplist.DpEastListDO;
import cn.iocoder.yudao.module.erp.dal.mysql.dpeast.DpEastListMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;

/**
 * 总东线清单 Service 实现类
 * @author 天使管理员
 */
@Service
@Validated
public class DpEastListServiceImpl implements DpEastListService {

    @Resource
    private DpEastListMapper dpEastListMapper;

    @Override
    public Long createDpEastList(DpEastListSaveReqVO createReqVO) {
        // 插入
        DpEastListDO dpEastList = BeanUtils.toBean(createReqVO, DpEastListDO.class);
        dpEastListMapper.insert(dpEastList);
        // 返回
        return dpEastList.getId();
    }

    @Override
    public void updateDpEastList(DpEastListSaveReqVO updateReqVO) {
        DpEastListDO updateObj = BeanUtils.toBean(updateReqVO, DpEastListDO.class);
        dpEastListMapper.updateById(updateObj);
    }

    @Override
    public void deleteDpEastList(Long id) {
        dpEastListMapper.deleteById(id);
    }

    @Override
    public DpEastListDO getDpEastList(Long id) {
        return dpEastListMapper.selectById(id);
    }

    @Override
    public PageResult<DpEastListDO> getDpEastListPage(DpEastListPageReqVO pageReqVO) {
        return dpEastListMapper.selectPage(pageReqVO);
    }

}